package com.feiyu.sys.utils

/**
 * Created by zdy on 2017/11/25.
 */
final class RandomUtils {
    /** 用于随机选的字符和数字 */
    static final String ALLCHAR = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

    /**
     * 返回一个定长的随机字符串(只包含大小写字母、数字)
     * @param length
     * @return
     */
    static String getString(int length) {
        StringBuilder sb = new StringBuilder()
        Random random = new Random()
        for (int i = 0; i < length; i++) {
            sb.append(ALLCHAR.charAt(random.nextInt(ALLCHAR.length())))
        }
        return sb.toString()
    }
}
